package com.monkeyboy.mytest.controller;

import java.sql.SQLException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import ru.yandex.clickhouse.ClickHouseConnection;
import ru.yandex.clickhouse.ClickHouseConnectionImpl;
import ru.yandex.clickhouse.ClickHouseDataSource;
import ru.yandex.clickhouse.settings.ClickHouseProperties;

/**
 * 作用： 测试控制器
 * 
 * @author Gavin
 * @time:2018年10月23日
 */
@Controller
@RequestMapping("/test")
public class TestController {
	public void connect() {
		ClickHouseConnection conn = null;
		ClickHouseProperties properties = new ClickHouseProperties();
		properties.setUser("hmt");
		properties.setPassword("Wbvc6G7f");
		properties.setDatabase("huang");
		try {
			ClickHouseDataSource dataSource = new ClickHouseDataSource("jdbc:clickhouse://192.168.25.130:8123",
					properties); // default表示数据表 ,port原来为8123
			ClickHouseConnectionImpl connection = (ClickHouseConnectionImpl) dataSource.getConnection();
			if (connection != null) {
				System.out.println("连接成功");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}